const mongoose = require("mongoose");
// const md5 = require("../middleware/md5");
const userSchema = new mongoose.Schema({
  username: {
    type: String,
    required: true,
    minlength: 2,
    maxlength: 10,
  },
  email: {
    type: String,
    unique: true,
  },
  password: {
    type: String,
    required: true,
  },
  role: {
    type: String,
    required: true,
  },
  state: {
    type: Number,
    default: 0,
  },
});
const User = mongoose.model("User", userSchema);

const aa = async () => {
  User.create({
    username: "cy",
    email: "111@qq.com",
    password: await md5("123"),
    role: "admin",
    state: 1,
  })
    .then((res) => {
      console.log(res);
    })
    .catch((err) => {
      console.error(err);
    });
};
// aa();
module.exports = {
  User,
};
